package com.college.express.base;

import android.app.Application;
import android.content.Context;

import androidx.annotation.Nullable;

import com.college.express.BuildConfig;
import com.orhanobut.logger.AndroidLogAdapter;
import com.orhanobut.logger.Logger;
import com.orhanobut.logger.PrettyFormatStrategy;

/**
 * @Description: JAVA类作用描述
 * @Author: LYJ
 * @CreateDate: 2021/4/14 14:07
 * @UpdateUser: LYJ
 * @UpdateDate: 2021/4/14 14:07
 * @UpdateRemark: 修改内容
 * @Version: 1.0
 */
public class BaseApplication extends Application {

  private static Context mContext;

  public static Context getContext() {
    return mContext;
  }

  @Override
  public void onCreate() {
    super.onCreate();
    mContext = this;

    //logger初始化
    initLogger();
  }

  /**
   * logger初始化
   */
  private void initLogger() {
    //logger初始化
    PrettyFormatStrategy formatStrategy = PrettyFormatStrategy.newBuilder()
        .showThreadInfo(false)  // (Optional) Whether to show thread info or not. Default true
        .methodCount(1)         // (Optional) How many method line to show. Default 2
        .tag("LOG")   // (Optional) Custom tag for each log. Default PRETTY_LOGGER
        .build();
    Logger.addLogAdapter(new AndroidLogAdapter(formatStrategy) {
      @Override
      public boolean isLoggable(int priority, @Nullable String tag) {
        return BuildConfig.DEBUG;
      }
    });
  }
}
